#include "geometrictransformationsdialog.h"
#include "ui_geometrictransformationsdialog.h"

GeometricTransformationsDialog::GeometricTransformationsDialog(OperationType op, QWidget *parent) :
    QDialog(parent),
    ui(new Ui::GeometricTransformationsDialog)
{
    m_transform_vector = glm::vec3(0.0,0.0,0.0);
    ui->setupUi(this);
    connect(ui->x_doubleSpinBox,SIGNAL(valueChanged(double)),this,SLOT(set_values()));
    connect(ui->y_doubleSpinBox,SIGNAL(valueChanged(double)),this,SLOT(set_values()));
    connect(ui->z_doubleSpinBox,SIGNAL(valueChanged(double)),this,SLOT(set_values()));
    connect(ui->angle_spinBox,SIGNAL(valueChanged(int)),this,SLOT(set_values()));
    ui->angle_frame->hide();
    switch(op){
    case TRANSLATION:
        ui->transform_label->setText("Translation");
        break;
    case ROTATION:
        ui->angle_frame->show();
        ui->x_doubleSpinBox->setMaximum(1);
        ui->y_doubleSpinBox->setMaximum(1);
        ui->z_doubleSpinBox->setMaximum(1);
        ui->x_doubleSpinBox->setMinimum(0);
        ui->y_doubleSpinBox->setMinimum(0);
        ui->z_doubleSpinBox->setMinimum(0);
        ui->transform_label->setText("Rotation");
        break;
    case SCALE:
        ui->x_doubleSpinBox->setValue(1);
        ui->y_doubleSpinBox->setValue(1);
        ui->z_doubleSpinBox->setValue(1);
        ui->transform_label->setText("Scale");
        break;
    default:
        break;
    }
    m_angle = 0;
}

GeometricTransformationsDialog::~GeometricTransformationsDialog()
{
    delete ui;
}

void GeometricTransformationsDialog::set_values()
{
    float x = ui->x_doubleSpinBox->value();
    float y = ui->y_doubleSpinBox->value();
    float z = ui->z_doubleSpinBox->value();
    m_transform_vector = glm::vec3(x,y,z);
    m_angle = ui->angle_spinBox->value();
}

glm::vec3 GeometricTransformationsDialog::get_vector()
{
    return m_transform_vector;
}

float GeometricTransformationsDialog::get_angle()
{
    return m_angle;
}
